<!--
 * @Description: In User Settings Edit
 * @Author: your name
 * @Date: 2019-08-05 15:16:04
 * @LastEditTime: 2019-12-08 12:48:16
 * @LastEditors: Please set LastEditors
 -->
<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport"
        content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>Hello APP</title>
    <link rel="stylesheet" type="text/css" href="../css/vant.css">
    <link rel="stylesheet" type="text/css" href="../css/base.css" />
    <script type="text/javascript" src="../script/jquery.js"></script>
    <script type="text/javascript" src="../script/layer/mobile/layer.js"></script>
    <script type="text/javascript" src="../script/vue.min.js"></script>
    <script type="text/javascript" src="../script/vant.min.js"></script>
    <script type="text/javascript" src="../script/fastclick.js"></script>
    <script type="text/javascript" src="../script/base.js"></script>
    <style type="text/css">
        .shadow {
            box-shadow: 0 0 5px rgb(200, 198, 198);
            position: relative;
            background: #fff;
        }

        .item .van-field__label {
            width: 60%;
            max-width: inherit;
        }

        .item .van-field__control {
            text-align: right;
        }

        .bottom_ {
            width: 100%;
            height: 50px;
            background: #efefef;
            position: relative;
            overflow: hidden;
        }
    </style>
</head>

<body>
    <div id="app" v-cloak>
        <div class="init-full">
            <van-nav-bar class="head" title="下单详情" left-arrow @click-left="onClickLeft">
                <div slot="right" class="head-right">

                </div>
            </van-nav-bar>
            <div class="body-with-bottom">
                <div class="content content-padding">
                    <div style="padding: 0 10px 15px;">
                        <div class="shadow">
                            <div class="content-label">基本信息</div>
                            <van-cell title="下单人" :value="detailData.ClientName"></van-cell>
                            <van-cell title="下单时间" :value="detailData.OrderDate.replace(/T/g,' ')">
                            </van-cell>

                        </div>
                    </div>

                    <div style="padding: 0 10px 15px;">
                        <div class="shadow">
                            <div class="content-label">商品明细</div>
                            <div class="item">
                                <van-field :label="row.ProductName" v-model="row.Num" readonly
                                    v-for="(row,index) in detailList">
                                </van-field>
                            </div>
                        </div>
                    </div>

                </div>
                <van-loading v-if="showLoading" />
            </div>
            <div :class="!detailData.Status?'bottom':'bottom_'">
                <div class="bottom-left-label_">
                    <!-- <span>合计:</span>
                    <span class="number">￥{{getTotalPrice()}}</span> -->
                </div>
                <div class="bottom-right-button_" v-show="!detailData.Status">
                    <div class="rad">
                        <van-button class="b-color-1" style="border-radius:15px 0 0 15px;" :disabled="ifConfirm"
                            :loading="ifConfirm" type="primary" @click="submitForm(2)">取消
                        </van-button>
                        <van-button class="b-color-2" style="border-radius:0 15px 15px 0;" :disabled="ifConfirm"
                            type="primary" :loading="ifConfirm" @click="submitForm(1)">同意
                        </van-button>

                    </div>

                </div>
            </div>
        </div>
    </div>
</body>

<script type="text/javascript">
    var vm;
    apiready = function () {
        //$('.init-full').show();

        var detailData = api.pageParam.detailData;
        var userInfo = FLD.getUserInfo();
        vm = new Vue({
            el: '#app',
            data: {
                showLoading: false,
                ifConfirm: false,
                detailData: detailData,
                detailList: []
            },
            created: function () {
                this.getDetailList();
            },
            methods: {
                getDetailList() {
                    var that = this;
                    that.showLoading = true;
                    var obj = {
                        BOrderID: that.detailData.BOrderID
                    }
                    FLD.ajax('getBSOrderDetail', obj, function (res) {
                        that.showLoading = false;
                        that.detailList = res.ds;
                    })

                },
                submitForm(index) {
                    var that = this;
                    var txt = '';
                    if (index == 1) {
                        txt = '是否同意当前下单请求?'
                    } else {
                        txt = '是否拒绝当前下单请求?'
                    }
                    that.$dialog.confirm({
                        title: '提示',
                        closeOnClickOverlay: true,
                        message: txt
                    }).then(() => {
                        that.ifConfirm = true;
                        var obj = {
                            BOrderID: that.detailData.BOrderID,
                            Status: index
                        }
                        FLD.ajax('updateBSOrder', obj, function (res) {
                            that.ifConfirm = false;
                            api.sendEvent({
                                name: 'refreshList'
                            });
                            api.sendEvent({
                                name: 'setDealNum'
                            });
                            layer.open({
                                content: '提交成功',
                                skin: 'msg',
                                time: 2,
                                end: function () {
                                    // api.closeWin();
                                }
                            });
                        })
                    }).catch(() => {

                    });
                },


                onClickLeft() {
                    api.closeWin();
                }
            }
        })
    };
</script>

</html>